﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using dhDataAcess.sysDAL;
using dhDataAcess.Model;


namespace dhDataAcess.baseBLL
{
    public static class basicSql
    {
        //返回一个查询表编号
        public static string queryNum(string userNum)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select top 1 queryNum from queryMaster where  userNum =@userNum order by recordID  desc";
            SqlParameter[] para = {
                                new SqlParameter ("@userNum",userNum),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string queryNum = null;
            while (rdr.Read())
            {
                queryNum  = rdr[0].ToString();
            }

            return queryNum ;
        }
        //返回一个moduleList表的mark值
        public static string moduleListSql(string moduleNum)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select mark from moduleList where moduleNum=@moduleNum";
            SqlParameter[] para = {
                                new SqlParameter ("@moduleNum",moduleNum),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string moduleName = null;
            while (rdr.Read())
            {
                moduleName = rdr[0].ToString();
            }

            return moduleName;
        }
        //返回ItemList列名称
        public static string itemListByitemName(int id)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select itemName from itemList where recordid=@id";
            SqlParameter[] para = {
                                new SqlParameter ("@id",id),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string itemName = null;
            while (rdr.Read())
            {
                itemName = rdr[0].ToString();
            }

            return itemName;
        }
        //返回ItemList列名称
        public static string getblStatus(string  orderNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select blStatus from orderDetail where orderNo=@orderNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderNo",orderNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string blStatus = null;
            while (rdr.Read())
            {
                blStatus = rdr[0].ToString();
            }

            return blStatus;
        }
        //返回胚带排期表状态
        public static string getpdpqbblStatus(string billoNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select billStatus from pdpqb where billoNo=@billoNo";
            SqlParameter[] para = {
                                new SqlParameter ("@billoNo",billoNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string blStatus = null;
            while (rdr.Read())
            {
                blStatus = rdr[0].ToString();
            }

            return blStatus;
        }
        //返回ItemList数据类型
        public static string itemListByitemDataType(int id)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select itemDataType from itemList where recordid=@id";
            SqlParameter[] para = {
                                new SqlParameter ("@id",id),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string itemDataType = null;
            while (rdr.Read())
            {
                itemDataType = rdr[0].ToString();
            }

            return itemDataType;
        }

        //更新基础表信息
        public static void baslistBasNumUpdate(string basType, string basNum,string basNameI)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update basList set basNum=@basNum,basNameI=@basNameI where basType=@basType ";
            SqlParameter[] para = {
                                new SqlParameter ("@basNum",basNum),
                                new SqlParameter ("@basType",basType),
                                new SqlParameter ("@basNameI",basNameI)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
             cmd.ExecuteNonQuery();
        }
        //返回一个基础表值
        public static string getOrderSerail(string basType)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select basNum from basList where basType=@basType";
            SqlParameter[] para = {
                                new SqlParameter ("@basType",basType),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string basNum = null;
            while (rdr.Read())
            {
                basNum = rdr[0].ToString();
            }

            return basNum;
        }


        //更新订单序列号 
        public static int  baslistBasNumUpdateOrderSerial(string basType)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.StoredProcedure;
           // int basNumNewValue=0;
            SqlParameter[] para = {
                                new SqlParameter ("@basType",basType)
                              };
   
            cmd.Parameters.AddRange(para);
            cmd.CommandText = "basicListUpdateNum";
             cmd.ExecuteNonQuery();
              //basNumNewValue;
             return 0;  //返回输出参数
        }


        //更新订单序列号，表值参数
        public static int productStockListInsert()
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.StoredProcedure;
            // int basNumNewValue=0;

            DataTable t = new DataTable();
            t.Columns.Add("stockNum",typeof(System.String));
            t.Columns.Add("pname", typeof(System.String));
            t.Columns.Add("stockQty", typeof(System.Decimal));
            t.Columns.Add("recordID", typeof(int));
            
            for (int i = 1; i < 5000; i++)
            {
                t.Rows.Add("08", "16修改"+i, 100, 20+i);
            }
            
            SqlParameter par = new SqlParameter("@protuctTable", t);
            par.SqlDbType = SqlDbType.Structured;
            par.TypeName = "dbo.pTable";


            cmd.Parameters.Add(par);
            cmd.CommandText = "productListStockInsert";
            return cmd.ExecuteNonQuery();
            //basNumNewValue;
            //return Convert.ToInt32(para[1].Value);  //返回输出参数
        }

        //存储过程
        public static int productStockListInsertIII(string stockNum,string pname,decimal stockQty)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.StoredProcedure;
            // int basNumNewValue=0;
            SqlParameter[] para = {
                                new SqlParameter ("@stockNum",stockNum),
                                new SqlParameter ("@pname",pname),
                                new SqlParameter ("@stockQty",stockQty)
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = "productStockListIIII";
            return cmd.ExecuteNonQuery();
            //basNumNewValue;
            //return Convert.ToInt32(para[1].Value);  //返回输出参数
        }
        //返回订单表状态
        public static string getOrderStatus(string orderNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select orderStatus from orderMaster where orderNo=@orderNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderNo",orderNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string orderStatus = null;
            while (rdr.Read())
            {
                orderStatus = rdr[0].ToString();
            }

            return orderStatus;
        }
        //返回领料出库单状态
        public static string getrlckStatus(string billNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select billStatus from rlckMaster where billNo=@billNo";
            SqlParameter[] para = {
                                new SqlParameter ("@billNo",billNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string billStatus = null;
            while (rdr.Read())
            {
                billStatus = rdr[0].ToString();
            }

            return billStatus;
        }
        //更新订单明细表状态
        public static int getDetailStatusUpdate(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update orderDetail set detailStatus='取消' where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
           i = cmd.ExecuteNonQuery();
           return i;
        }
        //更新订单明细表状态
        public static int getorderDetailStatusUpdate(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update orderDetail set detailStatus='已完结' where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新订单明细表状态
        public static int getorderDetailStatusUpdateI(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update orderDetail set detailStatus='染色完成' where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //返回包装明细
        public static string  getpackmark(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select CAST( COUNT(*)as NvarChar)+'×'+CAST( qty as NvarChar)+unit  as mark from V_packstockIn where orderDetailNo =@orderDetailNo and Status='新建' group by qty ,unit";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string mark = null;
            while (rdr.Read())
            {
              
                mark += rdr[0].ToString()+"+";
            }

            return mark;
        }
        //更新订单表状态
        public static int getorderStatusUpdate(string orderNo,string orderStatus)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update orderMaster set orderStatus=@orderStatus where orderNo=@orderNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderNo",orderNo),
                                new SqlParameter ("@orderStatus",orderStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新订单明细表备料状态
        public static int getblStatusUpdate(string orderNo, string blStatus)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update orderDetail set blStatus=@blStatus where orderNo=@orderNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderNo",orderNo),
                                new SqlParameter ("@blStatus",blStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新订单明细表数量
        public static int getorderDetailqtyUpdate(string orderDetailNo, string qty)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update orderDetail set qty=@qty where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                                new SqlParameter ("@qty",qty)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新订单表复期日期
        public static int getorderupdateDateUpdate(string orderNo, string updateDate)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update orderMaster set updateDate=@updateDate where orderNo=@orderNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderNo",orderNo),
                                new SqlParameter ("@updateDate",updateDate)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新包装订单明细表状态
        public static int getpackStockInMasterbillStatusUpdate(string orderDetailNo, string billStatus)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update V_packstockIn set billStatus=@billStatus where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                                new SqlParameter ("@billStatus",billStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新出库表状态
        public static int getV_orderStockOutUpdate(string orderDetailNo, string billStatus)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update V_orderStockOut set billStatus=@billStatus where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                                new SqlParameter ("@billStatus",billStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新包装状态
        public static int getVpackbaobiaoUpdate(string billNo, string billStatus)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update packStockInMaster set billStatus=@billStatus where billNo=@billNo";
            SqlParameter[] para = {
                                new SqlParameter ("@billNo",billNo),
                                new SqlParameter ("@billStatus",billStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新出库订单明细表状态
        public static int getpackStockOutMasterbillStatusUpdate(string billNo, string billStatus)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update V_orderStockOut set billStatus=@billStatus where billNo=@billNo";
            SqlParameter[] para = {
                                new SqlParameter ("@billNo",billNo),
                                new SqlParameter ("@billStatus",billStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新订单明细表状态
        public static int getdetailStatusUpdatebypname(string pname, string blStatus)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update orderDetail set blStatus=@blStatus where pname=@pname";
            SqlParameter[] para = {
                                new SqlParameter ("@pname",pname),
                                new SqlParameter ("@blStatus",blStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新订单明细表状态
        public static int getdetailStatusUpdate(string orderDetailNo, string detailStatus)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update orderDetail set detailStatus=@detailStatus where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                                new SqlParameter ("@detailStatus",detailStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新订单明细表状态
        public static int getpdpqbStatusUpdate(string orderDetailNo, string billStatus)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update pdpqb set billStatus=@billStatus where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                                new SqlParameter ("@billStatus",billStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新订单明细表状态
        public static int getpdpqbDel(string billoNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "delete pdpqb where billoNo=@billoNo";
            SqlParameter[] para = {
                                new SqlParameter ("@billoNo",billoNo)
                              
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新排期表状态
        public static int getpdpqbbillStatusUpdate(string billoNo, string billStatus)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update pdpqb set billStatus=@billStatus where billoNo=@billoNo";
            SqlParameter[] para = {
                                new SqlParameter ("@billoNo",billoNo),
                                new SqlParameter ("@billStatus",billStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新领料出库单状态
        public static int getrlckStatusUpdate(string billNo, string billStatus)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update rlckMaster set billStatus=@billStatus where billNo=@billNo";
            SqlParameter[] para = {
                                new SqlParameter ("@billNo",billNo),
                                new SqlParameter ("@billStatus",billStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新包装出库记录状态
        public static int getVpackStockInSummarkUpdate(string orderDetailNo, string Status)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update V_packstockIn set Status=@Status where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                                new SqlParameter ("@Status",Status)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新出库记录状态
        public static int getorderStockOutDetailUpdate(string orderDetailNo, string mark, string billNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update orderStockOutDetail set mark=@mark where orderDetailNo=@orderDetailNo and billNo=@billNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                                new SqlParameter ("@mark",mark),
                                new SqlParameter ("@billNo",billNo)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //返回单位转换率转换成码
        public static string getUnitrateY(string unitstart)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select qtyend from productunitrate where unitstart=@unitstart and unitend='Y'";
            SqlParameter[] para = {
                                new SqlParameter ("@unitstart",unitstart),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
           string   qtyend=null  ;
            while (rdr.Read())
            {
                qtyend = rdr[0].ToString();
            }

            return qtyend;
        }
        //返回单位转换率转换成罗
        public static string  getUnitrateL(string unitstart)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select qtyend from productunitrate where unitstart=@unitstart and unitend='GR'";
            SqlParameter[] para = {
                                new SqlParameter ("@unitstart",unitstart),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string qtyend = null;
            while (rdr.Read())
            {
                qtyend = rdr[0].ToString();
            }

            return qtyend;
        }
        //返回单位转换率转换成米
        public static string getUnitrateM(string unitstart)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select qtyend from productunitrate where unitstart=@unitstart and unitend='M'";
            SqlParameter[] para = {
                                new SqlParameter ("@unitstart",unitstart),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string qtyend = null;
            while (rdr.Read())
            {
                qtyend = rdr[0].ToString();
            }

            return qtyend;
        }
        //返回单位转换率转换成公斤
        public static string getUnitrateKg(string unitstart)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select qtyend from productunitrate where unitstart=@unitstart and unitend='Kg'";
            SqlParameter[] para = {
                                new SqlParameter ("@unitstart",unitstart),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string qtyend = null;
            while (rdr.Read())
            {
                qtyend = rdr[0].ToString();
            }

            return qtyend;
        }
        //返回单位由公斤转换成罗米码
        public static string getUnitrateKgTo(string unitend)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select qtyend from productunitrate where unitstart='Kg' and unitend=@unitend";
            SqlParameter[] para = {
                                new SqlParameter ("@unitend",unitend),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string qtyend = null;
            while (rdr.Read())
            {
                qtyend = rdr[0].ToString();
            }

            return qtyend;
        }
        //返回单位由罗转换成米码
        public static string getUnitrateGRTo(string unitend)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select qtyend from productunitrate where unitstart='GR' and unitend=@unitend";
            SqlParameter[] para = {
                                new SqlParameter ("@unitend",unitend),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string qtyend = null;
            while (rdr.Read())
            {
                qtyend = rdr[0].ToString();
            }

            return qtyend;
        }
        //返回生产已发胚数量
        public static string getSendQty(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select SUM(sendQty) from pdfpjlb  where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string sendQty = null;
            while (rdr.Read())
            {
                sendQty = rdr[0].ToString();
            }

            return sendQty;
        }
        //返回胚带库存数量
        public static string getstockQtyKG(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select stockQty from orderDetail  where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string stockQtyKG = null;
            while (rdr.Read())
            {
                stockQtyKG = rdr[0].ToString();
            }

            return stockQtyKG;
        }
        //返回已包装数
        public static string getV_packInSUM(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select qty from V_packInSUM  where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string qty = null;
            while (rdr.Read())
            {
                qty = rdr[0].ToString();
            }

            return qty;
        }
        //返回已出库数
        public static string getV_orderStockOutSUM(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select qty from V_orderStockOutSUM  where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string qty = null;
            while (rdr.Read())
            {
                qty = rdr[0].ToString();
            }

            return qty;
        }
        //返回订单出库数量
        public static string getorderstockQty(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select sum(qty) from orderStockOutDetail  where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string qty = null;
            while (rdr.Read())
            {
                qty = rdr[0].ToString();
            }

            return qty;
        }
        //返回订单数量根据订单明细表漂染单号
        public static string getqtybyorderDetail(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select qty from orderDetail  where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string qty = null;
            while (rdr.Read())
            {
                qty = rdr[0].ToString();
            }

            return qty;
        }
        //返回产品名称根据订单明细表
        public static string getpnamebyorderDetail(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select pname from orderDetail  where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string pname = null;
            while (rdr.Read())
            {
                pname  = rdr[0].ToString();
            }

            return pname ;
        }
        //返回单位根据订单明细表
        //public static string getunitbyorderDetail(string orderDetailNo)
        //{
        //    SqlCommand cmd = new SqlCommand();
        //    cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
        //    cmd.CommandType = CommandType.Text;
        //    string selectStr = "select pname from orderDetail  where orderDetailNo=@orderDetailNo";
        //    SqlParameter[] para = {
        //                        new SqlParameter ("@orderDetailNo",orderDetailNo),
        //                      };

        //    cmd.Parameters.AddRange(para);
        //    cmd.CommandText = selectStr;
        //    SqlDataReader rdr = cmd.ExecuteReader();
        //    string unit = null;
        //    while (rdr.Read())
        //    {
        //        unit = rdr[0].ToString();
        //    }

        //    return unit;
        //}
        //返回单位根据订单明细表
        public static string getunitbyorderDetail(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select unit from orderDetail  where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string unit = null;
            while (rdr.Read())
            {
                unit = rdr[0].ToString();
            }

            return unit;
        }
        //返回箱号根据包装入库表
        public static int  getcountbyorderDetail(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select count(*) from packStockInDetail  where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            int boxno = 1;
            while (rdr.Read())
            {
                boxno = Convert.ToInt32(rdr[0].ToString());
            }

            return boxno;
        }
        //返回产品类型根据产品表
        public static string getptypebyproductList(string pname)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select ptype from productList  where pname=@pname";
            SqlParameter[] para = {
                                new SqlParameter ("@pname",pname),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string ptype = null;
            while (rdr.Read())
            {
                ptype = rdr[0].ToString();
            }

            return ptype;
        }
        //返回原材料名称根据原材料表
        public static string getmatNamebymaterialList(string matNum)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select matName from materialList  where matNum=@matNum";
            SqlParameter[] para = {
                                new SqlParameter ("@matNum",matNum),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string matName = null;
            while (rdr.Read())
            {
                matName = rdr[0].ToString();
            }

            return matName;
        }
        //返回原材料库存根据原材料表
        public static string getstockqtybymaterialList(string matNum)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select stockqty from materialList  where matNum=@matNum";
            SqlParameter[] para = {
                                new SqlParameter ("@matNum",matNum),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string stockqty = null;
            while (rdr.Read())
            {
                stockqty = rdr[0].ToString();
            }

            return stockqty;
        }
        //返回胚带重量根据产品表
        public static string getgrwightbyproductList(string pname)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select grwight from productList  where pname=@pname";
            SqlParameter[] para = {
                                new SqlParameter ("@pname",pname),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string grwight = null;
            while (rdr.Read())
            {
                grwight = rdr[0].ToString();
            }

            return grwight;
        } 
        //返回胚带重量根据产品表
        //public static string getgrwightbyproductList(string pname)
        //{
        //    SqlCommand cmd = new SqlCommand();
        //    cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
        //    cmd.CommandType = CommandType.Text;
        //    string selectStr = "select grwight from productList  where pname=@pname";
        //    SqlParameter[] para = {
        //                        new SqlParameter ("@pname",pname),
        //                      };

        //    cmd.Parameters.AddRange(para);
        //    cmd.CommandText = selectStr;
        //    SqlDataReader rdr = cmd.ExecuteReader();
        //    string grwight = null;
        //    while (rdr.Read())
        //    {
        //        grwight = rdr[0].ToString();
        //    }

        //    return grwight;
        //} 
        //返回胚带重量根据产品表
        public static string getstockQtybyproductList(string pname)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select stockQty from productList  where pname=@pname";
            SqlParameter[] para = {
                                new SqlParameter ("@pname",pname),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string stockQty = null;
            while (rdr.Read())
            {
                stockQty = rdr[0].ToString();
            }

            return stockQty;
        }
        //返回包装胚带重量根据产品表
        public static string getpackwightbyproductList(string pname)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select packwight from productList  where pname=@pname";
            SqlParameter[] para = {
                                new SqlParameter ("@pname",pname),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string packwight = null;
            while (rdr.Read())
            {
                packwight = rdr[0].ToString();
            }

            return packwight;
        }
        //返回生产方式根据产品表
        public static string getproTypebyproductList(string pname)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select pmode from productList  where pname=@pname";
            SqlParameter[] para = {
                                new SqlParameter ("@pname",pname),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string proType = null;
            while (rdr.Read())
            {
                proType = rdr[0].ToString();
            }

            return proType;
        }
        //返回胚带开度根据BOM表
        public static string getendopenbypbomMark(string pname)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select endopen from pbomMark  where pname=@pname";
            SqlParameter[] para = {
                                new SqlParameter ("@pname",pname),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string endopen = null;
            while (rdr.Read())
            {
                endopen = rdr[0].ToString();
            }

            return endopen;
        }
        //返回每日每头产量根据BOM表
        public static string getproductionKfbypbomMark(string pname)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select productionKf from pbomMark  where pname=@pname";
            SqlParameter[] para = {
                                new SqlParameter ("@pname",pname),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string productionKf = null;
            while (rdr.Read())
            {
                productionKf = rdr[0].ToString();
            }

            return productionKf;
        }
        //返回单位根据原材料表
        public static string getunitbymaterialList(string matNum)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select unit from materialList  where matNum=@matNum";
            SqlParameter[] para = {
                                new SqlParameter ("@matNum",matNum),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string unit = null;
            while (rdr.Read())
            {
                unit = rdr[0].ToString();
            }

            return unit;
        }
        //返回规格根据原材料表
        public static string getMatLotbymaterialList(string matNum)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select MatLot from materialList  where matNum=@matNum";
            SqlParameter[] para = {
                                new SqlParameter ("@matNum",matNum),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string MatLot = null;
            while (rdr.Read())
            {
                MatLot = rdr[0].ToString();
            }

            return MatLot;
        }
        //返回规格根据原材料表
        public static string getmatSpecbymaterialList(string matNum)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select matSpec from materialList  where matNum=@matNum";
            SqlParameter[] para = {
                                new SqlParameter ("@matNum",matNum),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string matSpec = null;
            while (rdr.Read())
            {
                matSpec = rdr[0].ToString();
            }

            return matSpec;
        }
        ////返回单位根据原材料表
        //public static string getunitbymaterialList(string matNum)
        //{
        //    SqlCommand cmd = new SqlCommand();
        //    cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
        //    cmd.CommandType = CommandType.Text;
        //    string selectStr = "select matSpec from materialList  where matNum=@matNum";
        //    SqlParameter[] para = {
        //                        new SqlParameter ("@matNum",matNum),
        //                      };

        //    cmd.Parameters.AddRange(para);
        //    cmd.CommandText = selectStr;
        //    SqlDataReader rdr = cmd.ExecuteReader();
        //    string unit = null;
        //    while (rdr.Read())
        //    {
        //        unit = rdr[0].ToString();
        //    }

        //    return unit;
        //}
        //返回查询生产通知单数据条数
        public static int getintbyorderProduceList(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select * from orderProduceList  where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i =Convert .ToInt32 ( cmd.ExecuteScalar());
         
            return i ;
        }
        //更新胚带发胚表状态
        public static int getpdfpStatusUpdate(string recordid)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update pdfpjlb set billStatus='开始染色' where recordid=@recordid";
            SqlParameter[] para = {
                                new SqlParameter ("@recordid",recordid),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新胚带发胚表状态
        public static int getpdfpStatusUpdateend(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update pdfpjlb set orderStatus='染色完成' where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新包装入库状态
        public static int getpackStockInMasterUpdatebillStatus(string billNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update packStockInMaster set billStatus='已出库' where billNo=@billNo";
            SqlParameter[] para = {
                                new SqlParameter ("@billNo",billNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新胚带发胚表状态机原因
        public static int getpdfpStatusmarkUpdate(string recordid, string mark)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update pdfpjlb set billStatus='染色完成',dyestatus=@dyestatus,dyeDate=@dyeDate where recordid=@recordid";
            SqlParameter[] para = {
                                new SqlParameter ("@recordid",recordid),
                                new SqlParameter ("@dyestatus",mark),
                                  new SqlParameter ("@dyeDate",DateTime .Now ),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新胚带排期表状态机原因
        public static int getpdpqbStatusmarkUpdate(string billoNo, string mark)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update pdpqb set billStatus='染色完成',dyeDate=@dyeDate,mark=@mark where billoNo=@billoNo";
            SqlParameter[] para = {
                                new SqlParameter ("@billoNo",billoNo),
                                new SqlParameter ("@mark",mark),
                                  new SqlParameter ("@dyeDate",DateTime .Now ),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //返回胚带库存数量
        public static string getstockQty(string pname)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select stockQty from productList  where pname=@pname";
            SqlParameter[] para = {
                                new SqlParameter ("@pname",pname),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string stockQty = null;
            while (rdr.Read())
            {
                stockQty = rdr[0].ToString();
            }

            return stockQty;
        }
        //更新织带胚带重量
        public static int getproductawightUpdate(string pname, string grwight)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update productList set grwight=@grwight where pname=@pname";
            SqlParameter[] para = {
                                new SqlParameter ("@pname",pname),
                                new SqlParameter ("@grwight",grwight)
                                
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //更新包装胚带重量
        public static int getproductpackwightUpdate1(string pname, string packwight)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update productList set packwight=@packwight where pname=@pname";
            SqlParameter[] para = {
                                new SqlParameter ("@pname",pname),
                                new SqlParameter ("@packwight",packwight)
                                
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            int i;
            i = cmd.ExecuteNonQuery();
            return i;
        }
        //打印生产通知单
        public static SqlDataReader getproduceNo(List<string> list, string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_packbiaoqian where boxno in ({0}) and  orderDetailNo=@orderDetailNo";
            string ids = "";
            foreach (var item in list)
            {
                ids += ",'" + item.ToString() + "'";
            }
            ids = ids.Substring (1);
           
            sql = string.Format (sql, ids);
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader ();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr ;
           
        }
        //返回客户根据订单表订单号
        public static string getcustNumbyorderMaster(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select custName from V_orderproduceTable  where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string custNum = null;
            while (rdr.Read())
            {
                custNum = rdr[0].ToString();
            }

            return custNum;
        }
        //返回客户根据客户表
        public static string getcustNumbycustList(string custName)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select custNum from custList  where custName=@custName";
            SqlParameter[] para = {
                                new SqlParameter ("@custName",custName),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string custNum = null;
            while (rdr.Read())
            {
                custNum = rdr[0].ToString();
            }

            return custNum;
        }
        //返回机器号根据产品名称
        public static string   getmachineNobymachineTable(string panme)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select machineNo from machineTable  where panme=@panme";
            SqlParameter[] para = {
                                new SqlParameter ("@panme",panme),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            //DataSet ds = new DataSet();
            //SqlDataAdapter da = new SqlDataAdapter(selectStr, dhDataAcess.baseBLL.dataConn.connOpen());
            //return da.Fill(ds);

            SqlDataReader rdr = cmd.ExecuteReader();
            string machineNo = null;
            string machineNo1 = null;
            while (rdr.Read())
            {
                machineNo = rdr[0].ToString();
                machineNo1 = rdr[1].ToString();
            }

            return machineNo;
        }
        //返回地址根据订单表订单号
        public static string getaddressbyorderMaster(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select address from V_orderproduceTable  where orderDetailNo=@orderDetailNo";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            SqlDataReader rdr = cmd.ExecuteReader();
            string address = null;
            while (rdr.Read())
            {
                address = rdr[0].ToString();
            }

            return address;
        }
        //返回领料出库表
        public static SqlDataReader getscrlDetail(string billNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from scrlDetail where billNo=@billNo";
            SqlParameter[] para = {
                                new SqlParameter ("@billNo",billNo),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //打印工艺表
        public static SqlDataReader getpbomaster(string pname)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_pboMaster where pname=@pname";
            SqlParameter[] para = {
                                new SqlParameter ("@pname",pname),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;
            
        }
        //返回订单明细表
        public static SqlDataReader getorderDetail()
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from orderDetail where (detailStatus='已处理' or detailStatus='新建'or detailStatus='取消排期') and colorNum=''";
        

            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
          //返回订单明细表
        public static SqlDataReader getorderDetailfuse(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from orderDetail where (detailStatus='已处理' or detailStatus='新建') and colorNum!=''and (orderDetailNo like @orderDetailNo or pname like @orderDetailNo)";

            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回订单明细表
        public static SqlDataReader getorderDetailNofuse(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from orderDetail where (detailStatus='已处理' or detailStatus='新建') and colorNum=''and (orderDetailNo like @orderDetailNo or pname like @orderDetailNo)";

            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回订单明细表
        public static SqlDataReader getorderDetailII()
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from orderDetail where (detailStatus='已处理' or detailStatus='新建'or detailStatus='取消排期') and colorNum!=''";
          


            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回订单明细表
        public static SqlDataReader getorderDetailIII(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
           // string sql = "select * from orderDetail where ( detailStatus='欠数') and colorNum=''and (orderDetailNo like @orderDetailNo or pname like @orderDetailNo)";
            string sql = "select * from V_piaoranpaiqi where (billStatus='欠数' or mark='欠数' )and billStatus!='染色完成'and (orderDetailNo like @orderDetailNo or pname like @orderDetailNo) ";
            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回订单明细表
        public static SqlDataReader getorderDetailIIII(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from orderDetail where (detailStatus='已处理' or detailStatus='新建'or detailStatus='取消排期') and colorNum!=''and (orderDetailNo like @orderDetailNo or colorNum like @orderDetailNo )";

            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回包装主表
        public static SqlDataReader getpackmaster(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from packStockInMaster where billNo like @orderDetailNo";

            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回订单明细表
        public static SqlDataReader getVpackCount(string custName, string custPoNo, string hetongNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from VpackCount where  custName=@custName and custPoNo like @custPoNo and hetongNo like @hetongNo ";

            SqlParameter[] para = {
                                new SqlParameter ("@custPoNo",custPoNo),
                                new SqlParameter ("@custName",custName),
                                new SqlParameter ("@hetongNo",hetongNo),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回原材料表
        public static SqlDataReader getmaterialList(string supplier, string matSpec, string matLot,string matName)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from materialList where  supplier like @supplier and matSpec like @matSpec and matLot like @matLot and matName like @matName and stockName ='原材料仓'";

            SqlParameter[] para = {
                                new SqlParameter ("@matSpec",matSpec),
                                new SqlParameter ("@supplier",supplier),
                                new SqlParameter ("@matLot",matLot),
                                 new SqlParameter ("@matName",matName),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回原材料库存表
        public static SqlDataReader getV_materialStockList(string matName)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_materialStockList where  matName like @matName and stockName!='五金仓'";

            SqlParameter[] para = {
                                new SqlParameter ("@matName",matName),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回五金库存表
        public static SqlDataReader getV_materialStockListwj(string matName)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_materialStockList where  matName like @matName and stockName='五金仓'";

            SqlParameter[] para = {
                                new SqlParameter ("@matName",matName),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回包装表
        public static SqlDataReader getVpackbaobiaoIIII(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from Vpackbaobiao where billStatus='包装中' and (orderDetailNo like @orderDetailNo or colorNum like @orderDetailNo)"; 

            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回包装表
        public static SqlDataReader getVpackbaobiaoI(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from Vpackbaobiao where billStatus='包装完成' and (orderDetailNo like @orderDetailNo or colorNum like @orderDetailNo)";

            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回订单明细表
        public static SqlDataReader getorderDetailIIIIII(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from orderDetail where detailStatus='欠数' and orderDetailNo like @orderDetailNo ";

            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回胚带排期表
        public static SqlDataReader getpdpqb()
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_piaoranpaiqi where (billStatus='开始染色' or billStatus='已发胚')";



            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回胚带排期表
        public static SqlDataReader getpdpqbqianshu()
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_piaoranpaiqi where (billStatus='欠数' )or (mark='欠数' )and (billStatus!='染色完成' )";



            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回胚带排期表
        public static SqlDataReader getpdpqbranseend()
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_piaoranpaiqi where (billStatus='染色完成')";



            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回胚带排期表
        public static SqlDataReader getpdpqbII(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_piaoranpaiqi where (billStatus='开始染色' or billStatus='已发胚')and (orderDetailNo like @orderDetailNo or colorNum like @orderDetailNo)";

            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };
            cmd.Parameters.AddRange(para);


            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回胚带排期表
        public static SqlDataReader getpdpqbIII(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_piaoranpaiqi where billStatus='染色完成'  and orderDetailNo like @orderDetailNo";

            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };
            cmd.Parameters.AddRange(para);

            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回订单表根据状态
        public static SqlDataReader getorderMasterlII()
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from orderMaster where orderStatus='审核' or orderStatus='已处理'";
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回漂染表
        public static SqlDataReader getV_piaoranpaiqi(string custName)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_piaoranpaiqi where billStatus='开始染色'  and custName like @custName";

            SqlParameter[] para = {
                                new SqlParameter ("@custName",custName),
                              };
            cmd.Parameters.AddRange(para);

            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回漂染表
        public static SqlDataReader getV_piaoranorder(string custName)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_piaoranorder where billStatus='已发胚'  and custName like @custName";

            SqlParameter[] para = {
                                new SqlParameter ("@custName",custName),
                              };
            cmd.Parameters.AddRange(para);

            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回漂染表
        public static SqlDataReader getV_piaoranpaiqiByorderDetailNo(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_piaoranpaiqi where billStatus='开始染色'  and orderDetailNo like @orderDetailNo";

            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };
            cmd.Parameters.AddRange(para);

            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回漂染表
        public static SqlDataReader getV_piaoranorderByorderDetailNoyifp(string orderDetailNo)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_piaoranorder where billStatus='已发胚'  and orderDetailNo like @orderDetailNo";

            SqlParameter[] para = {
                                new SqlParameter ("@orderDetailNo",orderDetailNo),
                              };
            cmd.Parameters.AddRange(para);

            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回漂染表
        public static SqlDataReader getV_piaoranorderbycustlist(string custName)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_piaoranorder where billStatus='已发胚'  and custName like @custName";

            SqlParameter[] para = {
                                new SqlParameter ("@custName",custName),
                              };
            cmd.Parameters.AddRange(para);

            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回漂染表
        public static SqlDataReader getV_piaoranpaiqibycustlist(string custName)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_piaoranpaiqi where billStatus='欠数'  and custName like @custName";

            SqlParameter[] para = {
                                new SqlParameter ("@custName",custName),
                              };
            cmd.Parameters.AddRange(para);

            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回染单号根据排期表
        public static SqlDataReader getorderDetailNobypdpqb()
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "select orderDetailNo from pdpqb  where billStatus='染色完成'";
   
            cmd.CommandText = selectStr;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;
        }
        //返回胚带入库表
        public static SqlDataReader getV_pdrk(string a, string b)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_pdrk where billDate between @a and @b";
            SqlParameter[] para = {
                                new SqlParameter ("@a",a),
                                new SqlParameter ("@b",b),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回生产备料报表
        public static SqlDataReader getV_productblbaobiao(string a, string b)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_productblbaobiao where createDate between @a and @b";
            SqlParameter[] para = {
                                new SqlParameter ("@a",a),
                                new SqlParameter ("@b",b),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回采购收货入库原材料报表
        public static SqlDataReader getV_cgshrkDetail(string a, string b)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_cgshrkDetail where billDate between @a and @b and stockName!='五金仓'";
            SqlParameter[] para = {
                                new SqlParameter ("@a",a),
                                new SqlParameter ("@b",b),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回采购收货入库五金报表
        public static SqlDataReader getV_cgshrkDetailwj(string a, string b)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_cgshrkDetail where billDate between @a and @b and stockName='五金仓'";
            SqlParameter[] para = {
                                new SqlParameter ("@a",a),
                                new SqlParameter ("@b",b),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回领料出库原材料报表
        public static SqlDataReader getV_rlckDetail(string a, string b)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_rlckDetail where billDate between @a and @b and stockName!='五金仓'";
            SqlParameter[] para = {
                                new SqlParameter ("@a",a),
                                new SqlParameter ("@b",b),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回领料出库五金报表
        public static SqlDataReader getV_rlckDetailwj(string a, string b)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_rlckDetail where billDate between @a and @b and stockName='五金仓'";
            SqlParameter[] para = {
                                new SqlParameter ("@a",a),
                                new SqlParameter ("@b",b),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回领料退库原材料报表
        public static SqlDataReader getV_rltkDetail(string a, string b)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_rltkDetail where billDate between @a and @b and stockName!='五金仓'";
            SqlParameter[] para = {
                                new SqlParameter ("@a",a),
                                new SqlParameter ("@b",b),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回领料退库五金报表
        public static SqlDataReader getV_rltkDetailwj(string a, string b)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_rltkDetail where billDate between @a and @b and stockName='五金仓'";
            SqlParameter[] para = {
                                new SqlParameter ("@a",a),
                                new SqlParameter ("@b",b),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回胚带出库表
        public static SqlDataReader getV_pdck(string a, string b)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_pdck where billDate between @a and @b";
            SqlParameter[] para = {
                                new SqlParameter ("@a",a),
                                new SqlParameter ("@b",b),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返发胚记录表
        public static SqlDataReader getfpjlb(string a, string b)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from pdfpjlb where createDate between @a and @b";
            SqlParameter[] para = {
                                new SqlParameter ("@a",a),
                                new SqlParameter ("@b",b),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回未出库表
        public static SqlDataReader getVpackCount(string a, string b)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from VpackCount where billDate between @a and @b";
            SqlParameter[] para = {
                                new SqlParameter ("@a",a),
                                new SqlParameter ("@b",b),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        //返回已出库表
        public static SqlDataReader getV_orderStockOut(string a, string b)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select * from V_orderStockOut where outDate between @a and @b";
            SqlParameter[] para = {
                                new SqlParameter ("@a",a),
                                new SqlParameter ("@b",b),
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter();
            return dr;

        }
        public static DataTable HeReportDetail(string pname)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select mark from  V_blprint where pname=@pname group by orderNo,mark ";
            SqlParameter[] para = {
                                new SqlParameter ("@pname",pname),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader dr = cmd.ExecuteReader();
            DataTable t = new DataTable();
            t.Load(dr);
            return t;
        }
        /// <summary>
        /// 查询原材料仓库存明细表
        /// </summary>
        /// <param name="labelName"></param>
        /// <returns></returns>
        public static DataTable getmaterialListstockDetail(string qcbillDate, string qmbillDate, string matName, string matSpec, string supplier, string mtype)
        {
            string qmbillDate1 = qmbillDate + " 23:59:59:000";
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select  matNum, mtype, matName, matSpec, supplier, matpord, Fzunit, matLot, stockName, posName, mark,"
                        + "isnull(stockQtyqc,0) +isnull((select sum(qty) from V_cgshrkDetail  where billDate<=@billDateqc and matNum =materialList.matNum  group by matNum ),0)"
            + "+isnull((select sum(qty) from V_rltkDetail   where billDate<=@billDateqc and matNum =materialList.matNum  group by matNum ),0)"
            + "-isnull((select sum(qty) from V_rlckDetail    where billDate<=@billDateqc and matNum =materialList.matNum  group by matNum ),0) as qtyqc,"
            + "isnull((select sum(qty) from V_cgshrkDetail  where billDate between @billDateqc and @billDateqm and matNum =materialList.matNum  group by matNum ),0)as rkqty,"
            + "isnull((select sum(qty) from V_rltkDetail   where billDate between @billDateqc and @billDateqm and matNum =materialList.matNum  group by matNum ),0) as tkqty,"
            + "isnull((select sum(qty) from V_rlckDetail    where billDate between @billDateqc and @billDateqm and matNum =materialList.matNum  group by matNum ),0)as ckqty,"
            + "isnull(stockQtyqc,0) +isnull((select sum(qty) from V_cgshrkDetail  where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0)"
            + "+isnull((select sum(qty) from V_rltkDetail   where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0)"
            + "-isnull((select sum(qty) from V_rlckDetail where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0) as qtyqm,"
             + "isnull((select sum(fqty) from V_cgshrkDetail  where billDate<=@billDateqc and matNum =materialList.matNum  group by matNum ),0)"
            + "+isnull((select sum(fqty) from V_rltkDetail   where billDate<=@billDateqc and matNum =materialList.matNum  group by matNum ),0)"
            + "-isnull((select sum(fqty) from V_rlckDetail    where billDate<=@billDateqc and matNum =materialList.matNum  group by matNum ),0) as fzqtyqc,"
            + "isnull((select sum(fqty) from V_cgshrkDetail  where billDate between @billDateqc and @billDateqm and matNum =materialList.matNum  group by matNum ),0)as fzrkqty,"
            + "isnull((select sum(fqty) from V_rltkDetail   where billDate between @billDateqc and @billDateqm and matNum =materialList.matNum  group by matNum ),0) as fztkqty,"
            + "isnull((select sum(fqty) from V_rlckDetail    where billDate between @billDateqc and @billDateqm and matNum =materialList.matNum  group by matNum ),0)as fzckqty,"
            + "isnull((select sum(fqty) from V_cgshrkDetail  where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0)"
            + "+isnull((select sum(fqty) from V_rltkDetail   where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0)"
            + "-isnull((select sum(fqty) from V_rlckDetail where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0) as fzqtyqm from materialList where matName like @matName and matSpec like @matSpec and supplier like @supplier and mtype like @mtype and stockName='原材料仓'";
            SqlParameter[] para = {
                                 new SqlParameter ("@billDateqc",qcbillDate),
                                  new SqlParameter ("@billDateqm",qmbillDate1),
                                  new SqlParameter ("@matName",matName),
                                  new SqlParameter ("@matSpec",matSpec),
                                  new SqlParameter ("@supplier",supplier),
                                  new SqlParameter ("@mtype",mtype),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader rdr = cmd.ExecuteReader();
            DataTable t = new DataTable();
            t.Load(rdr);
            return t;

        }

        /// <summary>
        /// 查询原材料仓库存明细表
        /// </summary>
        /// <param name="labelName"></param>
        /// <returns></returns>
        public static DataTable getmaterialListstockDetailALL(string qcbillDate, string qmbillDate, string matName, string matSpec, string supplier, string mtype)
        {
            string qmbillDate1 = qmbillDate + " 23:59:59:000";
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select  matNum, mtype, matName, matSpec, supplier, matpord, Fzunit, matLot, stockName, posName, mark,"
            + "isnull(stockQtyqc,0) as qtyqc,"
+ "isnull((select sum(qty) from V_cgshrkDetail  where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0)as rkqty,"
+ "isnull((select sum(qty) from V_rltkDetail   where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0) as tkqty,"
+ "isnull((select sum(qty) from V_rlckDetail    where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0)as ckqty,"
+ "isnull(stockQtyqc,0) +isnull((select sum(qty) from V_cgshrkDetail  where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0)"
+ "+isnull((select sum(qty) from V_rltkDetail   where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0)"
+ "-isnull((select sum(qty) from V_rlckDetail    where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0) as qtyqm,"
+"0 as fzqtyqc,"
+ "isnull((select sum(fqty) from V_cgshrkDetail  where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0)as fzrkqty,"
+ "isnull((select sum(fqty) from V_rltkDetail   where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0) as fztkqty,"
+ "isnull((select sum(fqty) from V_rlckDetail    where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0)as fzckqty,"
+ "isnull((select sum(fqty) from V_cgshrkDetail  where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0)"
+ "+isnull((select sum(fqty) from V_rltkDetail   where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0)"
+ "-isnull((select sum(fqty) from V_rlckDetail    where billDate<=@billDateqm and matNum =materialList.matNum  group by matNum ),0) as fzqtyqm from materialList where matName like @matName and matSpec like @matSpec and supplier like @supplier and mtype like @mtype and stockName='原材料仓'";
            SqlParameter[] para = {
                                 new SqlParameter ("@billDateqc",qcbillDate),
                                  new SqlParameter ("@billDateqm",qmbillDate1),
                                  new SqlParameter ("@matName",matName),
                                  new SqlParameter ("@matSpec",matSpec),
                                  new SqlParameter ("@supplier",supplier),
                                  new SqlParameter ("@mtype",mtype),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader rdr = cmd.ExecuteReader();
            DataTable t = new DataTable();
            t.Load(rdr);
            return t;

        }
        /// <summary>
        /// 查询胚带仓库存明细表
        /// </summary>
        /// <param name="labelName"></param>
        /// <returns></returns>
        public static DataTable getproductListDetailALL(string qcbillDate, string qmbillDate, string pname, string ptype)
        {
            string qmbillDate1 = qmbillDate + " 23:59:59:000";
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select  ptype, pname,grwight, stockposition, mark,"
            + "isnull(stockQtyQC,0)  as qtyqc,"
+ "isnull((select sum(qty) from V_pdrk  where billDate<=@billDateqm and pName =productList.pname  group by pName ),0)as rkqty,"
+ "isnull((select sum(sendQty) from pdfpjlb   where sendDate<=@billDateqm and pname =productList.pname  group by pname ),0) as fpqty,"
+ "isnull((select sum(qty) from V_pdck    where billDate<=@billDateqm and pName =productList.pname  group by pName ),0)as ckqty,"
+ "stockQtyQC +isnull((select sum(qty) from V_pdrk  where billDate<=@billDateqm and pName =productList.pname  group by pName ),0)"
+ "-isnull((select sum(sendQty) from pdfpjlb   where sendDate<=@billDateqm and pName =productList.pname  group by pName ),0)"
+ "-isnull((select sum(qty) from V_pdck    where billDate<=@billDateqm and pName =productList.pname  group by pName ),0) as qtyqm,"
             + "case  grwight  when 0.00 then 0 else  convert(decimal(10,2),(stockQtyQC +isnull((select sum(qty) from V_pdrk  where billDate<=@billDateqm and pName =productList.pname  group by pName ),0)"
             + "-isnull((select sum(sendQty) from pdfpjlb   where sendDate<=@billDateqm and pname =productList.pname  group by pname ),0)"
             + "-isnull((select sum(qty) from V_pdck where billDate<=@billDateqm and pName =productList.pname  group by pName ),0))/grwight )end as GR from productList where pname like @pname   and ptype like @ptype ";
            SqlParameter[] para = {
                                 new SqlParameter ("@billDateqc",qcbillDate),
                                  new SqlParameter ("@billDateqm",qmbillDate1),
                                  new SqlParameter ("@pname",pname),
                                  new SqlParameter ("@ptype",ptype),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader rdr = cmd.ExecuteReader();
            DataTable t = new DataTable();
            t.Load(rdr);
            return t;

        }
        /// <summary>
        /// 查询胚带仓库存明细表
        /// </summary>
        /// <param name="labelName"></param>
        /// <returns></returns>
        public static DataTable getproductListDetail(string qcbillDate, string qmbillDate, string pname, string ptype)
        {
            string qmbillDate1 = qmbillDate + " 23:59:59:000";
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string sql = "select  ptype, pname,grwight, stockposition, mark,"
                         + "isnull(stockQtyQC,0) +isnull((select sum(qty) from V_pdrk  where billDate<=@billDateqc and pName =productList.pname  group by pName ),0)"
             + "-isnull((select sum(sendQty) from pdfpjlb   where sendDate<=@billDateqc and pname =productList.pname  group by pname ),0)"
             + "-isnull((select sum(qty) from V_pdck    where billDate<=@billDateqc and pName =productList.pname  group by pName ),0) as qtyqc,"
             + "isnull((select sum(qty) from V_pdrk  where billDate between @billDateqc and @billDateqm and pName =productList.pname  group by pName ),0) as rkqty,"
             + "isnull((select sum(sendQty) from pdfpjlb   where sendDate between @billDateqc and @billDateqm and pname =productList.pname  group by pname ),0) as fpqty,"
             + "isnull((select sum(qty) from V_pdck    where billDate between @billDateqc and @billDateqm and pName =productList.pname  group by pName ),0) as ckqty,"
             + "stockQtyQC +isnull((select sum(qty) from V_pdrk  where billDate<=@billDateqm and pName =productList.pname  group by pName ),0)"
             + "-isnull((select sum(sendQty) from pdfpjlb   where sendDate<=@billDateqm and pname =productList.pname  group by pname ),0)"
             + "-isnull((select sum(qty) from V_pdck where billDate<=@billDateqm and pName =productList.pname  group by pName ),0) as qtyqm,"
             + "case  grwight  when 0.00 then 0 else  convert(decimal(10,2),(stockQtyQC +isnull((select sum(qty) from V_pdrk  where billDate<=@billDateqm and pName =productList.pname  group by pName ),0)"
             + "-isnull((select sum(sendQty) from pdfpjlb   where sendDate<=@billDateqm and pname =productList.pname  group by pname ),0)"
             + "-isnull((select sum(qty) from V_pdck where billDate<=@billDateqm and pName =productList.pname  group by pName ),0))/grwight )end as GR from productList where pname like @pname   and ptype like @ptype ";
            SqlParameter[] para = {
                                 new SqlParameter ("@billDateqc",qcbillDate),
                                  new SqlParameter ("@billDateqm",qmbillDate1),
                                  new SqlParameter ("@pname",pname),
                                  new SqlParameter ("@ptype",ptype),
                              };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = sql;
            SqlDataReader rdr = cmd.ExecuteReader();
            DataTable t = new DataTable();
            t.Load(rdr);
            return t;

        }
        //结算原材料采购收货入库单据
        public static void cgshrkMasterUpdate(string qcbillDate, string qmbillDate, string billStatus)
        {
            string qmbillDate1 = qmbillDate + " 23:59:59:000";
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update cgshrkMaster set billStatus=@billStatus where billDate between @billDateqc and @billDateqm";
            SqlParameter[] para = {
                                 new SqlParameter ("@billDateqc",qcbillDate),
                                  new SqlParameter ("@billDateqm",qmbillDate1),
                                new SqlParameter ("@billStatus",billStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            cmd.ExecuteNonQuery();
        }
        //结算原材料采购收货退库单据
        public static void cgthckMasterUpdate(string qcbillDate, string qmbillDate, string billStatus)
        {
            string qmbillDate1 = qmbillDate + " 23:59:59:000";
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update cgthckMaster set billStatus=@billStatus where billDate between @billDateqc and @billDateqm";
            SqlParameter[] para = {
                                 new SqlParameter ("@billDateqc",qcbillDate),
                                  new SqlParameter ("@billDateqm",qmbillDate1),
                                new SqlParameter ("@billStatus",billStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            cmd.ExecuteNonQuery();
        }
        //结算原材料领料出库入库单据
        public static void rlckMasterUpdate(string qcbillDate, string qmbillDate, string billStatus)
        {
            string qmbillDate1 = qmbillDate + " 23:59:59:000";
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update rlckMaster set billStatus=@billStatus where billDate between @billDateqc and @billDateqm";
            SqlParameter[] para = {
                                 new SqlParameter ("@billDateqc",qcbillDate),
                                  new SqlParameter ("@billDateqm",qmbillDate1),
                                new SqlParameter ("@billStatus",billStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            cmd.ExecuteNonQuery();
        }
        //结算原材料领料退库入库单据
        public static void rltkMasterUpdate(string qcbillDate, string qmbillDate, string billStatus)
        {
            string qmbillDate1 = qmbillDate + " 23:59:59:000";
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update rltkMaster set billStatus=@billStatus where billDate between @billDateqc and @billDateqm";
            SqlParameter[] para = {
                                 new SqlParameter ("@billDateqc",qcbillDate),
                                  new SqlParameter ("@billDateqm",qmbillDate1),
                                new SqlParameter ("@billStatus",billStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            cmd.ExecuteNonQuery();
        }
        //结算胚带仓胚带入库单据
        public static void pdrkMasterUpdate(string qcbillDate, string qmbillDate, string billStatus)
        {
            string qmbillDate1 = qmbillDate + " 23:59:59:000";
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update pdrkMaster set billStatus=@billStatus where billDate between @billDateqc and @billDateqm";
            SqlParameter[] para = {
                                 new SqlParameter ("@billDateqc",qcbillDate),
                                  new SqlParameter ("@billDateqm",qmbillDate1),
                                new SqlParameter ("@billStatus",billStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            cmd.ExecuteNonQuery();
        }
        //结算胚带仓胚带出库单据
        public static void pdckMasterUpdate(string qcbillDate, string qmbillDate, string billStatus)
        {
            string qmbillDate1 = qmbillDate + " 23:59:59:000";
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = dhDataAcess.baseBLL.dataConn.connOpen();
            cmd.CommandType = CommandType.Text;
            string selectStr = "update pdckMaster set billStatus=@billStatus where billDate between @billDateqc and @billDateqm";
            SqlParameter[] para = {
                                 new SqlParameter ("@billDateqc",qcbillDate),
                                  new SqlParameter ("@billDateqm",qmbillDate1),
                                new SqlParameter ("@billStatus",billStatus)
                              };

            cmd.Parameters.AddRange(para);
            cmd.CommandText = selectStr;
            cmd.ExecuteNonQuery();
        }
    }
}
